package com.project.springboot.controller;

import com.project.springboot.enumparam.GenderIdCodeEnum;
import com.project.springboot.service.enumparam.EnumParamService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * description: 测试枚举参数API
 * @author 朱正磊
 * @date 2024-01-18 15:05:12
 */
@RestController
@RequestMapping("/enum/param")
public class EnumParamController {

    @Resource
    private EnumParamService enumParamService;

    /**
     * description: 获取性别枚举名称
     * @author 朱正磊
     * @date 2024-01-18 15:09:54
     * @param gender 性别枚举对象
     * @return 返回性别枚举名称
     */
    @GetMapping("/genderIdCode")
    public String genderIdCode(@RequestParam("gender") GenderIdCodeEnum gender) {
        return gender.name();
    }

    /**
     * description: 获取性别枚举名称
     * @author 朱正磊
     * @date 2024-01-18 15:09:54
     * @param gender 性别枚举对象
     * @return 返回性别枚举名称
     */
    @GetMapping("/genderIdCode2")
    public String genderIdCode2(@RequestParam("gender") GenderIdCodeEnum gender) {
        return enumParamService.genderIdCode2(gender);
    }

}
